<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

JHTML::_('behavior.calendar');
$editor =& JFactory::getEditor();

if ($this->row->id) {
	JToolBarHelper::title( JText::_( 'Edit Restaurant Review' ), 'addedit.png' );
} else {
	JToolBarHelper::title( JText::_( 'Add Restaurant Review' ), 'addedit.png' );
}

JToolBarHelper::save();
JToolBarHelper::apply();
if ($this->row->id) {
	JToolBarHelper::cancel( 'cancel', 'Close' );
} else {
	JToolBarHelper::cancel();
}

?>
<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
	if (pressbutton == 'save' || pressbutton == 'apply') {
		var quicktake = <?php echo $editor->getContent( 'quicktake' ); ?>
		if (document.adminForm.name.value == '') {
			alert("Please enter the name of the restaurant.");
		} else if (document.adminForm.address.value == '') {
			alert("Please enter the street address of the restaurant.");
		} else if (quicktake == '' && document.adminForm.quicktake.value == '') {
			alert("Please enter a quicktake summary of the restaurant.");
		} else {
			submitform(pressbutton);
		}
	} else {
		submitform(pressbutton);
	}
}
</script>
<form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
  <fieldset class="adminform">
    <legend>Details</legend>
    <table class="admintable">
    <tr>
      <td width="100" align="right" class="key">
        Name:
      </td>
      <td>
        <input class="text_area" type="text" name="name" id="name" size="50" maxlength="250" value="<?php echo $this->row->name;?>" />
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Address:
      </td>
      <td>
        <input class="text_area" type="text" name="address" id="address" size="50" maxlength="250" value="<?php echo $this->row->address;?>" />
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Reservations:
      </td>
      <td>
        <?php echo $this->reservations; ?>
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Quicktake:
      </td>
      <td>
        <?php
        echo $this->editor->display( 'quicktake',  $this->row->quicktake, '100%', '150', '40', '5' ) ;
        ?>
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Review:
      </td>
      <td>
        <?php
        echo $this->editor->display( 'review',  $this->row->review, '100%', '250', '40', '10' ) ;
        ?>
      </td>
    </tr> 
    <tr>
      <td width="100" align="right" class="key">
        Notes:
      </td>
      <td>
        <textarea class="text_area" cols="20" rows="4" name="notes" id="notes" style="width:500px"><?php echo $this->row->notes; ?></textarea>
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Smoking:
      </td>
      <td>
        <?php echo $this->smoking; ?>
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Credit Cards:
      </td>
      <td>
        <input class="text_area" type="text" name="credit_cards" 
           id="credit_cards" size="50" maxlength="250" 
           value="<?php echo $this->row->credit_cards;?>" />
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Cuisine:
      </td>
      <td>
        <input class="text_area" type="text" name="cuisine" 
           id="cuisine" size="31" maxlength="31" 
           value="<?php echo $this->row->cuisine;?>" />
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Average Dinner Price:
      </td>
      <td>
        $<input class="text_area" type="text" 
             name="avg_dinner_price" 
             id="avg_dinner_price" size="5" maxlength="3" 
             value="<?php echo $this->row->avg_dinner_price;?>" />
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Review Date:
      </td>
      <td>
		<?php echo $this->review_date; ?>
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Published:
      </td>
      <td>
        <?php echo $this->published; ?>
      </td>
    </tr>
    <tr>
      <td width="100" align="right" class="key">
        Audio File:
      </td>
      <td>
        <input type="file" name="audiofile" value="" />
      </td>
    </tr>
    </table>
  </fieldset>
  <input type="hidden" name="id" value="<?php echo $this->row->id; ?>" />
  <input type="hidden" name="option" value="<?php echo $option;?>" />
  <input type="hidden" name="task" value="" />
  <?php echo JHTML::_( 'form.token' ); ?>
</form>